﻿<script>
    $(function () {
        var $PluginType = $('#PluginType');
        var $settingTemplate = $('#Settings_Editor');
        var koModel = $settingTemplate.data('KO_ViewModel');
        $PluginType.change(function () {
            $.post('@Html.Raw(Url.Action("GetPluginParameters", "SubmissionSetting", ViewContext.RequestContext.AllRouteValues()))'
                , { type: $(this).val() })
            .done(function (data) {

                koModel.data.removeAll();
                _.each(data.Model, function (model) {
                    koModel.data.push(model);
                });
            });
        });
        setTimeout(function () {
            if (koModel.data().length == 0) {
                $PluginType.trigger('change');
            }
        }, 10);
    });
</script>
